All Packages This Package Previous Next
java.lang.Object
|
+----yassl.pnode
|
+----yassl.javaproc
New functions callable from yassl are created by subclassing javaproc and implementing the abstract apply method, and simply placing the new class along with the other support classes.
Here is an example of creating a procedure puts in yassl, which takes a string as its only argument and writing it through System.out.println.
public class yasslProcputs extends javaproc
{
public pnode apply(pnode args[]) throws yasslError
{
if (args.length != 1)
{ throw new yasslError("puts expects 1 argument", this); }
pnode s = actuals[0];
if (!(s instanceof stringnode))
{ throw new yasslError("puts expects arg #1 to be a string", this); }
System.out.println(((stringnode)s).val);
return (parser.NULL);
}
}
It should be properly subclassed from lambdanode, but done
this way to save unnecessary space and work. Fix this? ;-)
public Env saved_env
public javaproc()
public final pnode eval(Env e)
public abstract pnode apply(pnode actuals[]) throws yasslError
public String help(Env e)
All Packages This Package Previous Next